package com.rui.study.algorithm.L_深入拆解JVM_反射;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @program: study
 * @description:
 * @author: Yaowr
 * @create: 2018-12-13 17:05
 **/
public class FooV1 {

    public static void target(int i) {
        new Exception("#" + i).printStackTrace();
    }


    private static void reflectInvokeTest() {
        try {
            Class cls = Class.forName("com.rui.study.algorithm.L_深入拆解JVM_反射.FooV1");
            Method method = cls.getMethod("target", int.class);

            long current = System.currentTimeMillis();
            for (int i = 1; i <= 2_0; i++) {
                method.invoke(null, i);
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        reflectInvokeTest();
    }
}
